package com.itheima.mMothodDemo;

import java.util.Scanner;

/*
    求绝对值
 */
public class Work02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个小数:");
        double num = sc.nextDouble();
        System.out.println("绝对值为:"+getNum(num));
    }

    /*
         功能:取绝对值并返回     getNum()
         条件:小数类型数字       double num
         结果:返回绝对值         return
     */
    public static double getNum(double num) {
        if (num >= 0) {
            num = num;
        } else {
            num = 0 - num;
        }
        return num;
    }
}
